<template>
    <div id="nav">
        <nav>
            <div class="nav-header">
                <h1>
                    <a href="" class="navbar-brand">LawZhuo.</a>
                </h1>
                <button @click="choiceNav">
                    <i class="fa fa-duotone fa-align-right"></i>
                </button>
            </div>
            <!-- <transition name="fade"> -->
            <div class="nav-bottom" :class="mark ? 'transform10' : 'transform0'">
                <!-- <div class="nav-bottom"> -->
                <a href="#home">Home</a>
                <a href="#About">About</a>
                <a href="#Works">My Works</a>
                <a href="#Contact">Contact</a>
            </div>
            <!-- </transition> -->
        </nav>
    </div>
</template>

<script setup>
import { onMounted, reactive, ref } from 'vue';
import scrollReveal from 'scrollreveal';

const data = reactive({
    scrollReveal: scrollReveal()
});
const retScroll = (param) => {
    data.scrollReveal.reveal(param, {
        duration: 500,
        delay: 500,
        origin: 'top',
        mobile: true,
        distance: '1rem',
        easing: 'linear',
    });
};

const navigation = [
    { name: 'Dashboard', href: '#', current: true },
    { name: 'Team', href: '#', current: false },
    { name: 'Projects', href: '#', current: false },
    { name: 'Calendar', href: '#', current: false }
];
onMounted(() => {
    retScroll('h1')
});

let mark = ref(true);
const choiceNav = function () {
    mark.value = !mark.value;
};
</script>

<style scoped lang="scss">
.transform0 {
    // transform: translateY(0);
    top: 3rem;
    // background: pink;
}
.transform10 {
    // transform: translateY(-9.9rem);
    top: -7rem;
}

#nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;

    nav {
        position: relative;
        box-sizing: border-box;

        .nav-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 1rem;
            height: 3rem;
            h1 {
                display: flex;
                align-items: center;
                justify-content: space-between;
                height: 100%;
                font-weight: 400;
                a {
                    font-size: 1rem;
                    // color: var(--color-grape);
                    color: transparent;
                    background: linear-gradient(to right, #191970, #00c78c);
                    background-clip: text;
                    -webkit-background-clip: text;
                    display: inline-block;
                    letter-spacing: 1.5px;
                }
            }
        }

        .nav-bottom {
            display: flex;
            flex-direction: column;
            padding: 0 1rem;
            width: 100%;

            z-index: 99;
            -webkit-transition: all ease-in-out 0.4s;
            transition: all ease-in-out 0.4s;
            a {
                position: relative;
                display: flex;
                align-items: center;
                font-size: 0.8rem;
                font-weight: normal;
                color: #656565;
                letter-spacing: 1.5px;
                -webkit-transition: all ease-in-out 0.4s;
                transition: all ease-in-out 0.4s;

                &::after {
                    content: '';
                    position: absolute;
                    bottom: 0;
                    display: block;
                    width: 0;
                    height: 0.1rem;
                    margin: auto;
                    background: transparent;
                    transition: width 0.3s ease, background-color 0.3s ease;
                }

                &:hover:after {
                    background: #000000;
                    color: #ffffff;
                    width: 20%;
                }
            }
        }
    }
}

@media (max-width: 768px) {
    #nav {
        box-shadow: 0 40px 100px rgba(0, 0, 0, 0.2);
    }
    nav {
        min-height: 3rem;
        width: 100%;
        .nav-header {
            position: relative;
            z-index: 100;
        }
        .nav-bottom {
            position: absolute;
            flex-direction: column;
            height: 10rem;
            box-shadow: 5px 0px 5px #d1d9e6, -5px 0px 5px #f9f9f9;
            a {
                height: 25%;
                &:last-child {
                    margin-bottom: 0.5rem;
                }
                &:hover:after {
                    width: 20%;
                }
                &:nth-child(1):hover:after {
                    width: 50%;
                }
                &:nth-child(2):hover:after {
                    width: 30%;
                }
                &:nth-child(3):hover:after {
                    width: 46%;
                }
                &:nth-child(4):hover:after {
                    width: 45%;
                }
            }
        }
    }
}

@media (min-width: 768px) {
    #nav {
        // box-shadow:0 40px 100px rgba(0,0,0,.2);
        nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin: 0 auto;
            // height: 3.6rem;
            // width: 80%;
            button {
                display: none;
            }
            .nav-bottom {
                display: flex;
                flex-direction: row;
                justify-content: right;
                height: 100%;
                a {
                    margin: 0 1rem;
                    height: 100%;
                    &::after {
                        bottom: -0.5rem;
                    }
                    &:hover:after {
                        width: 100%;
                    }
                }
            }
        }
    }
}
@media screen and (min-width: 768px) and (max-width: 1024px) {
    #nav {
        nav {
            // height: 3rem;
            width: 95%;
        }
    }
}
@media screen and (min-width: 1024px) and (max-width: 1680px) {
    #nav {
        box-shadow: 0 40px 100px rgba(0, 0, 0, 0.2);
        nav {
            // height: 3rem;
            width: 80%;
        }
    }
}
@media (min-width: 1680px) {
    #nav {
        // box-shadow:0 40px 100px rgba(0,0,0,.2);
        nav {
            // height: 3rem;
            width: 70%;
        }
    }
}
</style>
